package com.redrose.demo.util;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.util.DisplayMetrics;

public class ContextUtil {
    private Context mContext;

    private static class Inner {
        @SuppressLint("StaticFieldLeak")
        private final static ContextUtil holder = new ContextUtil();
    }

    private ContextUtil() {
    }

    public static ContextUtil getInstance() {
        return Inner.holder;
    }

    public void init(Context context) {
        this.mContext = context;
    }

    public Context getContext() {
        return mContext;
    }

    public int getScreenHeight () {
        Resources resources = mContext.getResources();
        DisplayMetrics displayMetrics = resources.getDisplayMetrics();
        return displayMetrics.heightPixels;
    }

    public int getScreenWidth() {
        Resources resources = mContext.getResources();
        DisplayMetrics displayMetrics = resources.getDisplayMetrics();
        return displayMetrics.widthPixels;
    }
}
